<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
#top_login {
	position: absolute;
	/* z-index: 1; */
	background-color: white;
}

#nav {
	position: absolute;
	top: 32px;
}

#sea {
	position: absolute;
	top: 7px;
	left: 548px;
}

#logined {
	position: absolute;
	top: 6px;
	/* z-index: 0; */
	background-color: white;
	width: 600px;
	height: 22px;
}
</style>
<script type="text/javascript" src="/news/js/jquery-1.8.3.js"></script>
<%--
<script type="text/javascript">
	$(function() {
		
<%
			Object bs = session.getAttribute("userLoginState");
			if (bs == null) {//第一次进入页面
				Cookie[] cookies = request.getCookies();
				String name = NewsUtil.getValue(cookies, "nuName");
				String pass = NewsUtil.getValue(cookies, "nuPass");
				boolean b = name != "" && pass != ""
						&& (new UserServersImpl().login(name, pass)) > 0;
				if (b) {
					out.println("$(\"#top_login\").css(\"z-index\",\"0\");");
					out.println("$(\"#logined\").css(\"z-index\",\"1\");");
					session.setAttribute("userLoginState", true);
					session.setAttribute("userInfo", new UserInfo(name));
				}
			} else if ((Boolean) bs) { //登陆了就显示欢迎
				out.println("$(\"#top_login\").css(\"z-index\",\"0\");");
				out.println("$(\"#logined\").css(\"z-index\",\"1\");");
			} else {
				session.setAttribute("userLoginState", false);
			}

			Object uls = session.getAttribute("userLoginState");
			String nuName1 = "";
			if (uls != null) {
				if ((Boolean) uls) {
					nuName1 = ((UserInfo) (session.getAttribute("userInfo")))
							.getNuname();
				} else {
					out.print("alert('用户名或者密码有误！请检查');");
					session.setAttribute("userLoginState", null);
				}
			}%>
	})
</script>
--%>
</head>
<body>
	<div id="header">
		<c:if test="${sessionScope.userLoginState eq false}">
			<script>
				alert('用户名或者密码有误！请检查');
			</script>
			<c:set var="userLoginState" value="${null}" scope="session"></c:set>
		</c:if>
		<c:if test="${empty sessionScope.userLoginState}">
			<div id="top_login">
				<form action="UserLogin" method="post">
					<label> 登录名 </label> <input type="text" id="uname" name="uname"
						value="" class="login_input" /> <label> 密&#160;&#160;码 </label> <input
						type="password" id="upwd" name="upwd" value="" class="login_input" />
					<input type="submit" class="login_sub" value="登录" /> <select
						name="select">
						<option value="10">不</option>
						<option value="86400">一天</option>
						<option value="604800">一周</option>
						<option value="18144000">一月</option>
					</select> <label>免登陆</label> <label id="error"></label>
				</form>
				<img src="Images/friend_logo.gif" alt="Google" id="friend_logo" />
			</div>
		</c:if>
		<c:if test="${sessionScope.userLoginState eq true}">
			<div id="logined">
				你好${sessionScope.userInfo.nuname}，欢迎进入！&#160;&#160;&#160;&#160;<a
					href="UserExitLogin">注销</a>
			</div>
		</c:if>

		<div id="nav">
			<img src="Images/ad.gif" alt="" />
		</div>
		<div id="sea">
			<input type="text" id="seach" oninput="auto(this)">站内搜索
			<div style="background: #CCC" id="mult"></div>
		</div>
	</div>
	<script>
		/*搜索补全*/
		var xhr;
		function creat() {
			try {
				return new XMLHttpRequest();
			} catch (e) {
				return new ActiveXObject("Microsoft.httpxml");
			}
		}
		function auto(dom) {
			xhr = creat();
			var text = dom.value;
			xhr.onreadystatechange = callback;
			xhr.open("post", "Search", true);
			xhr.setRequestHeader("Content-type",
					"application/x-www-form-urlencoded");
			xhr.send("text=" + text);

		}
		function callback() {
			if (xhr.readyState == 4 && xhr.status == 200) {
				var dom = document.getElementById("mult");
				var returnStr = xhr.responseText;
				var strs = returnStr.split("<>");
				dom.innerHTML = "";
				var html = "";
				for (var i = 0; i < strs.length; i++) {
					html += "<div>" + strs[i] + "</div>\r\n";
				}
				dom.innerHTML = html;
			}
		}
	</script>
</body>
</html>